package com.nt.train.service.impl;

import com.nt.train.service.IMyBeanService;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author hlf
 * @version 1.0
 * @date 2022/9/28 21:03
 */
public class MyBeanMatchServiceImpl implements IMyBeanService, Condition {

    @Override
    public void hello() {
        System.out.println("up to matches...");
    }

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return "ok".equals(context.getEnvironment().getProperty("mybean.ok"));
    }
}
